package com.example.bysj_sb.service;

import com.example.bysj_sb.dao.GraduateProjectCacheDao;
import com.example.bysj_sb.domain.GraduateProject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Isolation;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;
//@Transactional注解：可以用在方法上和类上，用在类上代表这个类的所有公共非静态方法都将启用事务功能。
@Transactional(isolation = Isolation.READ_COMMITTED, propagation = Propagation. REQUIRED)
@Service("graduateProjectCacheService")
public class GraduateProjectCacheService {
    @Autowired
    private GraduateProjectCacheDao graduateProjectCacheDao;

    //添加
    public Boolean add(GraduateProject graduateProject){
        return graduateProjectCacheDao.add(graduateProject);
    }

    //查找全部teacherId对应的课题
    public List<GraduateProject> findByTeacherId(int teacher_id){
        List<GraduateProject> graduateProjects = graduateProjectCacheDao.findByTeacherId(teacher_id);
        return graduateProjects;
    }
    //修改
    public Boolean update(GraduateProject graduateProject){
        return graduateProjectCacheDao.update(graduateProject);
    }
    //删除
    public Boolean delete(int id){
        return graduateProjectCacheDao.delete(id);
    }
}